﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack )
            {
                Label3.Text  = " ";
            }
        }
        //登录

        protected void Button1_Click(object sender, EventArgs e)
        {
            var uid = this .Label1 .Text .Trim ();
            var pwd =this .Label2 .Text .Trim ();
            var sql = string.Format("select * from Users where Username='{0}'", uid);
            var dt = DbHelp.GetData(sql);
            if (dt .Rows .Count == 1)
            {
                var item = dt.Rows[0];
                var IsActived = (bool)item.ItemArray[3];
                var IsDeleted = (bool)item.ItemArray[4];
                if (IsDeleted)
                {
                    Label3.Text = "";
                }else if (IsActived )
                {
                    if (pwd == Password )
                    {
                        Response.Redirect("default.aspx");

                    }
                }
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

        }
    }
}